package com.olc.railing.dialog;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;


import com.olc.railing.utils.ToastUtils;
import com.olc.railing.R;

import butterknife.BindView;
import butterknife.OnClick;

public class ConfrimDialog extends BaseDialog {
    private String title;
    private String content;

    @BindView(R.id.title_tv)
    TextView title_tv;
    @BindView(R.id.content_tv)
    TextView content_tv;


    private  OnMySubmitListener onSubmit;

    public ConfrimDialog(Context context, String title, String content, OnMySubmitListener onSubmit) {
        super(context, title, content, 0, null);
        this.title = title;
        this.content = content;
        this.onSubmit = onSubmit;
    }

    @Override
    public int getlayoutId() {
        return R.layout.dialog_confrim;
    }

    @Override
    public void initView() {
        if(TextUtils.isEmpty(title)){
            ToastUtils.showToast(context,"标题不能为空");
            return;
        }
        if(TextUtils.isEmpty(content)){
            ToastUtils.showToast(context,"内容不能为空");
            return;
        }

        title_tv.setText(title);
        content_tv.setText(content);

    }
    @OnClick({R.id.tv_confirm, R.id.tv_cancel})
    public void onClick(View view){
        switch (view.getId()){
            case R.id.tv_confirm:
                dismiss();
                onSubmit.onSubmit("");
                break;
            case R.id.tv_cancel:
                dismiss();
                onSubmit.onClose();
                break;
        }
    }

    public interface OnMySubmitListener<T>{
        void onSubmit(T var);
        void onClose();

    }
}
